package top.healthylife.pangwa.server;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author Gaozexi on 2020/5/19 16:13
 * Step by Step  and Stand on,  You Are The Best Investment!
 */
@Configuration
@EnableConfigurationProperties(PangwaServerProperties.class)
@ConditionalOnClass(PangWaMarkerConfiguration.Marker.class)
@Import(PangWaController.class)
public class PangWaServerAutoConfiguration extends WebMvcConfigurerAdapter  implements WebServerFactoryCustomizer<ConfigurableWebServerFactory> {

    @Autowired
    private PangwaServerProperties properties;

    @Bean
    public Result getResult(){
        return new Result();
    }

    @Override
    public void customize(ConfigurableWebServerFactory factory) {
        factory.setPort(properties.getPort());
    }
}
